<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>loading加载动画效果</title>
    <link rel="stylesheet" href="./css/reset.css" />
    <style>
      body {
        background-color: #86cfeb;
      }

      .loading {
        width: 200px;
        height: 200px;
        background-color: #86cfeb;
        margin: 100px auto 0px;
        position: relative;
      }

      .loading .item {
        width: 20px;
        height: 20px;
        background-color: rgba(255, 255, 255, 0.2);
        border-radius: 50%;
        position: absolute;
        top: 0px;
        left: 50%;
        margin-left: -10px;
        /* 往矩形中心点移动 */
        transform-origin: 10px 100px;
        /* 调用自定义属性 */
        transform: rotate(calc(var(--i) * 40deg));
        animation: loading 2s ease infinite;
        animation-delay: calc(var(--i) * 0.11s);
      }

      @keyframes loading {
        /*前1秒为白色有透明*/
        0%,
        50% {
          background-color: rgba(255, 255, 255, 0.2);
        }
        /*后一秒 背景色为白色*/
        50.5%,
        100% {
          background-color: #fff;
        }
      }
    </style>
  </head>
  <body>
    <div class="loading">
      <!-- 自定义属性 style="--i: x" -->
      <div class="item" style="--i: 0"></div>
      <div class="item" style="--i: 1"></div>
      <div class="item" style="--i: 2"></div>
      <div class="item" style="--i: 3"></div>
      <div class="item" style="--i: 4"></div>
      <div class="item" style="--i: 5"></div>
      <div class="item" style="--i: 6"></div>
      <div class="item" style="--i: 7"></div>
      <div class="item" style="--i: 8"></div>
    </div>
  </body>
</html>
